<template>
  <div>
    <div>
      <el-button @click="toggleSelection()">取消选择</el-button>
    </div>
    <!--   v-for="item in tableData"
      :key="item.name" -->
    <el-table
      ref="multipleTable"
      tooltip-effect="dark"
      style="width: 100%;"
      @selection-change="handleSelectionChange"
      :data="tableData"
    >
      <el-table-column type="selection" width="55"> </el-table-column>
      <el-table-column
        prop="employeeNumber"
        label="社员番号"
        width="90px"
      ></el-table-column>
      <el-table-column
        prop="nameJapanese"
        label="姓名"
        width="120"
      ></el-table-column>
      <el-table-column prop="post" label="役職"> </el-table-column>
      <el-table-column prop="division" label="部署"> </el-table-column>
      <el-table-column prop="emailAddress" label="邮件地址"> </el-table-column>
      <el-table-column prop="enrollment" label="在籍状态"> </el-table-column>
      <el-table-column label="操作" width="180px">
        <template slot-scope="scope">
          <el-button type="primary" @click="edit(scope.row)">编辑</el-button>
          <el-button type="danger" @click="del">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import axios from "axios";

// yhl
export default {
  name: "EmpList",
  data() {
    return {
      empInfoAll: [],
      tableData: [
        {
          employeeNumber: "",
          nameJapanese: "",
          post: "",
          division: "",
          emailAddress: "",
          enrollment: "",
        },
      ],
    };
  },
  methods: {
    toggleSelection(rows) {
      if (rows) {
        rows.forEach((row) => {
          this.$refs.multipleTable.toggleRowSelection(row);
        });
      } else {
        this.$refs.multipleTable.clearSelection();
      }
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    edit(row) {
      // this.tableData.employeeNumber
      const aa = {
        t:"EmpDetail",
        u:row.employeeNumber
      }
      this.$bus.$emit("editName", aa);
    },
    del() {},
    queryAll() {
      axios.post("http://localhost:8089/bff/employee/info").then(
        (response) => {
          this.tableData = response.data.resultDto;
        },
        (error) => {
          console.log("请求失败", error.message);
        }
      );
    },
  },
  mounted() {
    this.queryAll();
  },
};
</script>